<html>
<head>
<link rel="shortcut icon" href="./favicon.ico">
<link rel="stylesheet" type="text/css" href="./style.css">
<link rel="canonical" href="./Pipeline_Sink.html">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Acts as either a pass-through or a sink for ready/valid pipeline handshakes, along with the associated data.  While `sink` is raised, any handshake and data presented at the input is immediately lost, and the output never raises valid and presents all-zero data.  *All signals must be synchronous. There is no buffering or registering.*">
<title>Pipeline Sink</title>
</head>
<body>

<p class="inline bordered"><b><a href="./Pipeline_Sink.v">Source</a></b></p>
<p class="inline bordered"><b><a href="./legal.html">License</a></b></p>
<p class="inline bordered"><b><a href="./index.html">Index</a></b></p>

<h1>Pipeline Sink</h1>
<p>Acts as either a pass-through or a sink for ready/valid pipeline
 handshakes, along with the associated data.  While <code>sink</code> is raised, any
 handshake and data presented at the input is immediately lost, and the
 output never raises valid and presents all-zero data.  <em>All signals must be
 synchronous. There is no buffering or registering.</em></p>
<p>The main use of a sink is to disconnect an output of a pipeline fork or
 branch so no backpressure can come from that output. Else, an inactive
 output will stall the handshakes to all the other outputs.</p>
<p>The default Annuller <code>IMPLEMENTATION</code> of "AND" should be fine. Check your
 synthesis results if necessary.</p>

<pre>
`default_nettype none

module <a href="./Pipeline_Sink.html">Pipeline_Sink</a>
#(
    parameter WORD_WIDTH        = 0,
    parameter IMPLEMENTATION    = "AND"
)
(
    input   wire                        sink,

    input   wire                        input_valid,
    output  reg                         input_ready,
    input   wire    [WORD_WIDTH-1:0]    input_data,

    output  wire                        output_valid,
    input   wire                        output_ready,
    output  wire    [WORD_WIDTH-1:0]    output_data
);

    initial begin
        input_ready = 1'b0;
    end
</pre>

<p>Annull all forward logic (data and valid) if sunk.</p>

<pre>
    localparam FORWARD_WIDTH = WORD_WIDTH + 1;

    <a href="./Annuller.html">Annuller</a>
    #(
        .WORD_WIDTH     (FORWARD_WIDTH),
        .IMPLEMENTATION (IMPLEMENTATION)
    )
    forward_sink
    (
        .annul          (sink),
        .data_in        ({input_data,  input_valid}),
        .data_out       ({output_data, output_valid})
    );
</pre>

<p>Present a perpetually ready input if sunk, so no stalling can happen.</p>

<pre>
    always @(*) begin
        input_ready = (sink == 1'b1) ? 1'b1 : output_ready;
    end

endmodule
</pre>

<hr>
<p><a href="./index.html">Back to FPGA Design Elements</a>
<center><a href="https://fpgacpu.ca/">fpgacpu.ca</a></center>
</body>
</html>

